package Greedy;

import java.util.Arrays;

public class _455_AssignCookies {
    //hint:use sort algorithm to sort the g and s ,then compare thw two's value
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int pos = 0;
        for (int i = 0; i < s.length; i++) {
            if (pos>=g.length) {
                break;
            }
            if (g[pos] <= s[i]) {
                count++;
                pos++;
            }
        }
        return count;
    }
}
